#pragma once
#include <Windows.h>
#include "Bridge.h"

class BridgeManager
{
private:
	list<Bridge *> bridgeList;
	CRITICAL_SECTION criticalSection;

	HANDLE hPipeThread;
	HANDLE hStoppedEvent;

public:
	BridgeManager();
	~BridgeManager();
	void LoadFromDB();
	HANDLE GetPipeStoppedEvent();

	void StartAll();
	void StopAll();
	void AddBridge(Bridge* bridge);
	void DeleteBridgeByName(string bridgeName);
	Bridge* GetBridgeByName(string bridgeName);

	list<Bridge*>& GetBridgeList();
	string SerializeBridges();

private:
	void LoadBridgesFromReg();
	BOOL RemoveFromRegistry(Bridge* bridge);
	void LoadFromRegistry(Bridge& bridge, const char* comName);
	BOOL SaveToRegistry(Bridge& bridge);

};

